package com.fawvwebanma.mapper;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fawvwebanma.dto.TrainPassStationDto;
import com.fawvwebanma.entity.Train;
import com.fawvwebanma.entity.TrainPassStation;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public interface TrainPassStationMapper extends BaseMapper<TrainPassStation> {
    @Select("select ts.*,s.station_name from trainpassstation ts INNER JOIN station s on s.station_num = ts.station_num where train_num = #{trainNum} order by sn asc")
    List<TrainPassStationDto> selectDtoByTrainNum(@Param("trainNum") String trainNum);

    @Select("select train_num,station_name from trainpassstation ts inner join station s on s.station_num = ts.station_num where station_name like concat('%',#{stationName},'%')")
    List<Train> getTrainByStationName(@Param("stationName") String stationName);
}
